﻿using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Conversation.Persuasion;
using TaleWorlds.CampaignSystem.Encounters;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.GameState;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x02000307 RID: 775
	public class GangLeaderNeedsWeaponsIssueQuestBehavior : CampaignBehaviorBase
	{
		// Token: 0x17000AFA RID: 2810
		// (get) Token: 0x06002D1A RID: 11546 RVA: 0x000BCF5A File Offset: 0x000BB15A
		private static int CreatedPartyCount
		{
			get
			{
				return Campaign.Current.GetCampaignBehavior<GangLeaderNeedsWeaponsIssueQuestBehavior>()._createdPartyCount;
			}
		}

		// Token: 0x06002D1B RID: 11547 RVA: 0x000BCF6B File Offset: 0x000BB16B
		public GangLeaderNeedsWeaponsIssueQuestBehavior()
		{
			this._createdPartyCount = 0;
		}

		// Token: 0x06002D1C RID: 11548 RVA: 0x000BCF7A File Offset: 0x000BB17A
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D1D RID: 11549 RVA: 0x000BCF93 File Offset: 0x000BB193
		public override void SyncData(IDataStore dataStore)
		{
			dataStore.SyncData<int>("_createdPartyCount", ref this._createdPartyCount);
		}

		// Token: 0x06002D1E RID: 11550 RVA: 0x000BCFA8 File Offset: 0x000BB1A8
		public void OnCheckForIssue(Hero hero)
		{
			if (this.ConditionsHold(hero))
			{
				Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnStartIssue), typeof(GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue), IssueBase.IssueFrequency.Common, null));
				return;
			}
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof(GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue), IssueBase.IssueFrequency.Common));
		}

		// Token: 0x06002D1F RID: 11551 RVA: 0x000BD00C File Offset: 0x000BB20C
		private bool ConditionsHold(Hero IssueOwner)
		{
			return IssueOwner.IsGangLeader && IssueOwner.CurrentSettlement != null && IssueOwner.CurrentSettlement.IsTown && IssueOwner.CurrentSettlement.Town.Loyalty < 60f;
		}

		// Token: 0x06002D20 RID: 11552 RVA: 0x000BD044 File Offset: 0x000BB244
		private IssueBase OnStartIssue(in PotentialIssueData pid, Hero issueOwner)
		{
			this._createdPartyCount++;
			return new GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue(issueOwner);
		}

		// Token: 0x06002D21 RID: 11553 RVA: 0x000BD05A File Offset: 0x000BB25A
		private static TextObject GetNeededClassTextObject(WeaponClass requestedWeaponClass)
		{
			if (requestedWeaponClass == WeaponClass.OneHandedAxe)
			{
				return new TextObject("{=tza4micZ}one-handed axes", null);
			}
			return new TextObject("{=!}Undefined!", null);
		}

		// Token: 0x04000D84 RID: 3460
		private const IssueBase.IssueFrequency GangLeaderNeedsWeaponsIssueFrequency = IssueBase.IssueFrequency.Common;

		// Token: 0x04000D85 RID: 3461
		private int _createdPartyCount;

		// Token: 0x04000D86 RID: 3462
		private static WeaponClass[] _canBeRequestedWeaponClassList = new WeaponClass[]
		{
			WeaponClass.OneHandedAxe
		};

		// Token: 0x02000627 RID: 1575
		public class GangLeaderNeedsWeaponsIssue : IssueBase
		{
			// Token: 0x06004BE1 RID: 19425 RVA: 0x0015CDC9 File Offset: 0x0015AFC9
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsWeaponsIssue(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004BE2 RID: 19426 RVA: 0x0015CDD7 File Offset: 0x0015AFD7
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004BE3 RID: 19427 RVA: 0x0015CDE0 File Offset: 0x0015AFE0
			internal static object AutoGeneratedGetMemberValue_requiredWeaponClassIndex(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue)o)._requiredWeaponClassIndex;
			}

			// Token: 0x06004BE4 RID: 19428 RVA: 0x0015CDF2 File Offset: 0x0015AFF2
			internal static object AutoGeneratedGetMemberValue_averagePriceForItem(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue)o)._averagePriceForItem;
			}

			// Token: 0x17000F60 RID: 3936
			// (get) Token: 0x06004BE5 RID: 19429 RVA: 0x0015CE04 File Offset: 0x0015B004
			public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
			{
				get
				{
					return IssueBase.AlternativeSolutionScaleFlag.Duration;
				}
			}

			// Token: 0x17000F61 RID: 3937
			// (get) Token: 0x06004BE6 RID: 19430 RVA: 0x0015CE08 File Offset: 0x0015B008
			private int RequestedWeaponAmount
			{
				get
				{
					float num;
					if (base.IssueDifficultyMultiplier >= 0.1f && base.IssueDifficultyMultiplier < 0.3f)
					{
						num = 0.1f;
					}
					else if (base.IssueDifficultyMultiplier >= 0.3f && base.IssueDifficultyMultiplier < 0.6f)
					{
						num = 0.2f;
					}
					else
					{
						num = 0.3f;
					}
					if (3 + this._averagePriceForItem == 0)
					{
						return 0;
					}
					return (int)((float)(20000 / this._averagePriceForItem) * num);
				}
			}

			// Token: 0x17000F62 RID: 3938
			// (get) Token: 0x06004BE7 RID: 19431 RVA: 0x0015CE81 File Offset: 0x0015B081
			private int CompanionGoldNeedForAlternativeSolution
			{
				get
				{
					return this.RewardGold / 2 + this._averagePriceForItem * this.RequestedWeaponAmount / 4;
				}
			}

			// Token: 0x17000F63 RID: 3939
			// (get) Token: 0x06004BE8 RID: 19432 RVA: 0x0015CE9B File Offset: 0x0015B09B
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return 2 + MathF.Ceiling(4f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F64 RID: 3940
			// (get) Token: 0x06004BE9 RID: 19433 RVA: 0x0015CEB0 File Offset: 0x0015B0B0
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return 7 + MathF.Ceiling(8f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F65 RID: 3941
			// (get) Token: 0x06004BEA RID: 19434 RVA: 0x0015CEC5 File Offset: 0x0015B0C5
			protected override int RewardGold
			{
				get
				{
					return 500 + this._averagePriceForItem * this.RequestedWeaponAmount;
				}
			}

			// Token: 0x17000F66 RID: 3942
			// (get) Token: 0x06004BEB RID: 19435 RVA: 0x0015CEDA File Offset: 0x0015B0DA
			private WeaponClass RequestedWeaponClass
			{
				get
				{
					return GangLeaderNeedsWeaponsIssueQuestBehavior._canBeRequestedWeaponClassList[this._requiredWeaponClassIndex];
				}
			}

			// Token: 0x17000F67 RID: 3943
			// (get) Token: 0x06004BEC RID: 19436 RVA: 0x0015CEE8 File Offset: 0x0015B0E8
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					return new TextObject("{=m24bXmOD}Yes, you can help me. Do you want to make some easy money? I need some 'tools' for my private business. Are you interested?[if:convo_bored][ib:confident2]", null);
				}
			}

			// Token: 0x17000F68 RID: 3944
			// (get) Token: 0x06004BED RID: 19437 RVA: 0x0015CEF5 File Offset: 0x0015B0F5
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=PFNXodyo}What sort of tools?", null);
				}
			}

			// Token: 0x17000F69 RID: 3945
			// (get) Token: 0x06004BEE RID: 19438 RVA: 0x0015CF04 File Offset: 0x0015B104
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=xBaL3RM4}Well, as you know we're not farmers or artisans. I need {NEEDED_AMOUNT} {.%}{NEEDED_TYPE}{.%}. Don't mind the quality, just buy the weapons. Bring them to me and {REWARD_GOLD}{GOLD_ICON} is yours. Got it?[if:convo_bored]", null);
					textObject.SetTextVariable("NEEDED_AMOUNT", this.RequestedWeaponAmount);
					textObject.SetTextVariable("REWARD_GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					textObject.SetTextVariable("NEEDED_TYPE", GangLeaderNeedsWeaponsIssueQuestBehavior.GetNeededClassTextObject(this.RequestedWeaponClass));
					return textObject;
				}
			}

			// Token: 0x17000F6A RID: 3946
			// (get) Token: 0x06004BEF RID: 19439 RVA: 0x0015CF68 File Offset: 0x0015B168
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=0i8RgslK}Or, maybe one of your trusted companions can buy the {ITEM_TYPE}. I reckon they'll cost {COMPANION_NEED_GOLD_AMOUNT}{GOLD_ICON} denars, and they'd best take at least {ALTERNATIVE_TROOP_AMOUNT} men for protection.[if:convo_bored]", null);
					textObject.SetTextVariable("COMPANION_NEED_GOLD_AMOUNT", this.CompanionGoldNeedForAlternativeSolution);
					textObject.SetTextVariable("ITEM_TYPE", GangLeaderNeedsWeaponsIssueQuestBehavior.GetNeededClassTextObject(this.RequestedWeaponClass));
					textObject.SetTextVariable("ALTERNATIVE_TROOP_AMOUNT", base.GetTotalAlternativeSolutionNeededMenCount());
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000F6B RID: 3947
			// (get) Token: 0x06004BF0 RID: 19440 RVA: 0x0015CFCC File Offset: 0x0015B1CC
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					TextObject textObject = new TextObject("{=ABYGws1M}I'll bring you {NEEDED_AMOUNT} of those by myself.", null);
					textObject.SetTextVariable("NEEDED_AMOUNT", this.RequestedWeaponAmount);
					return textObject;
				}
			}

			// Token: 0x17000F6C RID: 3948
			// (get) Token: 0x06004BF1 RID: 19441 RVA: 0x0015CFEB File Offset: 0x0015B1EB
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=Ggjb9BVQ}Actually I prefer not to get involved in this kind of business personally but my men will help you out.", null);
				}
			}

			// Token: 0x17000F6D RID: 3949
			// (get) Token: 0x06004BF2 RID: 19442 RVA: 0x0015CFF8 File Offset: 0x0015B1F8
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=HawJormK}That's fine, so long as your men know well enough to handle this quietly. Good luck.", null);
				}
			}

			// Token: 0x17000F6E RID: 3950
			// (get) Token: 0x06004BF3 RID: 19443 RVA: 0x0015D005 File Offset: 0x0015B205
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=aG9iX1a8}We're looking forward to trying out our new \"tools\" on some bastard's head. Let your boys know that drinks are on us when they get here.", null);
				}
			}

			// Token: 0x17000F6F RID: 3951
			// (get) Token: 0x06004BF4 RID: 19444 RVA: 0x0015D014 File Offset: 0x0015B214
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=otwfa0K3}{QUEST_GIVER.LINK}, a gang leader from {SETTLEMENT} wanted you to buy some weapons for {?QUEST_GIVER.GENDER}her{?}his{\\?} private business. {?QUEST_GIVER.GENDER}She{?}He{\\?} offers you {REWARD_GOLD}{GOLD_ICON} on their delivery. You asked {COMPANION.LINK} to take some of your men and buy {NEEDED_AMOUNT} units of {NEEDED_TYPE} to deliver to {QUEST_GIVER.LINK} in {SETTLEMENT}. They should rejoin your party in {RETURN_DAYS} days.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, textObject, false);
					textObject.SetTextVariable("SETTLEMENT", base.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("RETURN_DAYS", base.GetTotalAlternativeSolutionDurationInDays());
					textObject.SetTextVariable("NEEDED_AMOUNT", this.RequestedWeaponAmount);
					textObject.SetTextVariable("NEEDED_TYPE", GangLeaderNeedsWeaponsIssueQuestBehavior.GetNeededClassTextObject(this.RequestedWeaponClass));
					textObject.SetTextVariable("REWARD_GOLD", this.RewardGold);
					textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000F70 RID: 3952
			// (get) Token: 0x06004BF5 RID: 19445 RVA: 0x0015D0D8 File Offset: 0x0015B2D8
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x17000F71 RID: 3953
			// (get) Token: 0x06004BF6 RID: 19446 RVA: 0x0015D0DB File Offset: 0x0015B2DB
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F72 RID: 3954
			// (get) Token: 0x06004BF7 RID: 19447 RVA: 0x0015D0DE File Offset: 0x0015B2DE
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=zKHkS5Gf}Gang leader needs weapons", null);
				}
			}

			// Token: 0x17000F73 RID: 3955
			// (get) Token: 0x06004BF8 RID: 19448 RVA: 0x0015D0EC File Offset: 0x0015B2EC
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=VYq93e36}A gang leader needs you to buy weapons for {?QUEST_GIVER.GENDER}her{?}his{\\?} men.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x06004BF9 RID: 19449 RVA: 0x0015D120 File Offset: 0x0015B320
			public GangLeaderNeedsWeaponsIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(15f))
			{
				MBList<ValueTuple<WeaponClass, int>> mblist = new MBList<ValueTuple<WeaponClass, int>>();
				foreach (WeaponClass weaponClass in GangLeaderNeedsWeaponsIssueQuestBehavior._canBeRequestedWeaponClassList)
				{
					int num = this.CalculateAveragePriceForWeaponClass(weaponClass);
					if (num > 0)
					{
						mblist.Add(new ValueTuple<WeaponClass, int>(weaponClass, num));
					}
				}
				ValueTuple<WeaponClass, int> selectedItemAndPrize = mblist.GetRandomElement<ValueTuple<WeaponClass, int>>();
				this._averagePriceForItem = selectedItemAndPrize.Item2;
				this._requiredWeaponClassIndex = Array.FindIndex<WeaponClass>(GangLeaderNeedsWeaponsIssueQuestBehavior._canBeRequestedWeaponClassList, (WeaponClass x) => x == selectedItemAndPrize.Item1);
			}

			// Token: 0x06004BFA RID: 19450 RVA: 0x0015D1BA File Offset: 0x0015B3BA
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.SettlementSecurity)
				{
					return 1f;
				}
				if (issueEffect == DefaultIssueEffects.IssueOwnerPower)
				{
					return -0.2f;
				}
				return 0f;
			}

			// Token: 0x06004BFB RID: 19451 RVA: 0x0015D1DD File Offset: 0x0015B3DD
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				return new ValueTuple<SkillObject, int>((hero.GetSkillValue(DefaultSkills.Trade) >= hero.GetSkillValue(DefaultSkills.Crafting)) ? DefaultSkills.Trade : DefaultSkills.Crafting, 120);
			}

			// Token: 0x06004BFC RID: 19452 RVA: 0x0015D20C File Offset: 0x0015B40C
			private int CalculateAveragePriceForWeaponClass(WeaponClass weaponClass)
			{
				int num = 0;
				int num2 = 0;
				foreach (Settlement settlement in Settlement.All)
				{
					if (settlement.IsTown)
					{
						for (int i = 0; i < settlement.ItemRoster.Count; i++)
						{
							ItemRosterElement itemRosterElement = settlement.ItemRoster[i];
							WeaponComponent weaponComponent = itemRosterElement.EquipmentElement.Item.WeaponComponent;
							if (weaponComponent != null && weaponComponent.PrimaryWeapon.WeaponClass == weaponClass)
							{
								num2 += itemRosterElement.Amount;
								num += itemRosterElement.EquipmentElement.ItemValue;
							}
						}
					}
				}
				return num / ((num2 == 0) ? 1 : num2);
			}

			// Token: 0x06004BFD RID: 19453 RVA: 0x0015D2E4 File Offset: 0x0015B4E4
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x17000F74 RID: 3956
			// (get) Token: 0x06004BFE RID: 19454 RVA: 0x0015D2E6 File Offset: 0x0015B4E6
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return (int)(800f + 900f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x06004BFF RID: 19455 RVA: 0x0015D2FB File Offset: 0x0015B4FB
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false) && QuestHelper.CheckGoldForAlternativeSolution(this.CompanionGoldNeedForAlternativeSolution, ref explanation);
			}

			// Token: 0x06004C00 RID: 19456 RVA: 0x0015D32C File Offset: 0x0015B52C
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004C01 RID: 19457 RVA: 0x0015D344 File Offset: 0x0015B544
			public override bool IsTroopTypeNeededByAlternativeSolution(CharacterObject character)
			{
				return character.Tier >= 2;
			}

			// Token: 0x06004C02 RID: 19458 RVA: 0x0015D352 File Offset: 0x0015B552
			public override void AlternativeSolutionStartConsequence()
			{
				GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, this.CompanionGoldNeedForAlternativeSolution, false);
			}

			// Token: 0x06004C03 RID: 19459 RVA: 0x0015D368 File Offset: 0x0015B568
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				ChangeCrimeRatingAction.Apply(base.IssueOwner.CurrentSettlement.MapFaction, 10f, true);
				base.IssueOwner.AddPower(10f);
				this.RelationshipChangeWithIssueOwner = 5;
				base.IssueOwner.CurrentSettlement.Town.Security -= 30f;
			}

			// Token: 0x06004C04 RID: 19460 RVA: 0x0015D3C8 File Offset: 0x0015B5C8
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.Common;
			}

			// Token: 0x06004C05 RID: 19461 RVA: 0x0015D3CC File Offset: 0x0015B5CC
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				flag = IssueBase.PreconditionFlags.None;
				skill = null;
				relationHero = null;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				if (base.IssueOwner.CurrentSettlement.OwnerClan == Clan.PlayerClan)
				{
					flag |= IssueBase.PreconditionFlags.PlayerIsOwnerOfSettlement;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x06004C06 RID: 19462 RVA: 0x0015D420 File Offset: 0x0015B620
			public override bool IssueStayAliveConditions()
			{
				Settlement currentSettlement = base.IssueOwner.CurrentSettlement;
				return ((currentSettlement != null) ? currentSettlement.Town : null) != null && base.IssueOwner.CurrentSettlement.OwnerClan != Clan.PlayerClan && base.IssueOwner.CurrentSettlement.Town.Loyalty < 75f;
			}

			// Token: 0x06004C07 RID: 19463 RVA: 0x0015D47B File Offset: 0x0015B67B
			protected override void OnGameLoad()
			{
			}

			// Token: 0x06004C08 RID: 19464 RVA: 0x0015D47D File Offset: 0x0015B67D
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004C09 RID: 19465 RVA: 0x0015D47F File Offset: 0x0015B67F
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest(questId, base.IssueOwner, CampaignTime.DaysFromNow(25f), this.RewardGold, this._requiredWeaponClassIndex, this.RequestedWeaponAmount, base.IssueDifficultyMultiplier, this._averagePriceForItem);
			}

			// Token: 0x040019A3 RID: 6563
			private const int BaseNeededWeaponCount = 3;

			// Token: 0x040019A4 RID: 6564
			private const int BaseRewardGold = 500;

			// Token: 0x040019A5 RID: 6565
			private const int AlternativeSolutionTroopTierRequirement = 2;

			// Token: 0x040019A6 RID: 6566
			private const int RequiredSkillLevelForSendingComp = 120;

			// Token: 0x040019A7 RID: 6567
			private const int IssueDuration = 15;

			// Token: 0x040019A8 RID: 6568
			private const int QuestTimeLimit = 25;

			// Token: 0x040019A9 RID: 6569
			[SaveableField(20)]
			private int _requiredWeaponClassIndex;

			// Token: 0x040019AA RID: 6570
			[SaveableField(30)]
			private int _averagePriceForItem;
		}

		// Token: 0x02000628 RID: 1576
		public class GangLeaderNeedsWeaponsIssueQuest : QuestBase
		{
			// Token: 0x06004C0A RID: 19466 RVA: 0x0015D4B5 File Offset: 0x0015B6B5
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsWeaponsIssueQuest(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004C0B RID: 19467 RVA: 0x0015D4C3 File Offset: 0x0015B6C3
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._weaponsThatGuardTook);
				collectedObjects.Add(this._playerStartsQuestLog);
			}

			// Token: 0x06004C0C RID: 19468 RVA: 0x0015D4E4 File Offset: 0x0015B6E4
			internal static object AutoGeneratedGetMemberValue_randomForRequiredWeaponClass(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._randomForRequiredWeaponClass;
			}

			// Token: 0x06004C0D RID: 19469 RVA: 0x0015D4F6 File Offset: 0x0015B6F6
			internal static object AutoGeneratedGetMemberValue_requestedWeaponAmount(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._requestedWeaponAmount;
			}

			// Token: 0x06004C0E RID: 19470 RVA: 0x0015D508 File Offset: 0x0015B708
			internal static object AutoGeneratedGetMemberValue_playerDodgedGuards(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._playerDodgedGuards;
			}

			// Token: 0x06004C0F RID: 19471 RVA: 0x0015D51A File Offset: 0x0015B71A
			internal static object AutoGeneratedGetMemberValue_collectedItemAmount(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._collectedItemAmount;
			}

			// Token: 0x06004C10 RID: 19472 RVA: 0x0015D52C File Offset: 0x0015B72C
			internal static object AutoGeneratedGetMemberValue_lowCrimeRatingWillBeApplied(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._lowCrimeRatingWillBeApplied;
			}

			// Token: 0x06004C11 RID: 19473 RVA: 0x0015D53E File Offset: 0x0015B73E
			internal static object AutoGeneratedGetMemberValue_highCrimeRatingWillBeApplied(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._highCrimeRatingWillBeApplied;
			}

			// Token: 0x06004C12 RID: 19474 RVA: 0x0015D550 File Offset: 0x0015B750
			internal static object AutoGeneratedGetMemberValue_weaponsThatGuardTook(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._weaponsThatGuardTook;
			}

			// Token: 0x06004C13 RID: 19475 RVA: 0x0015D55D File Offset: 0x0015B75D
			internal static object AutoGeneratedGetMemberValue_issueDifficulty(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._issueDifficulty;
			}

			// Token: 0x06004C14 RID: 19476 RVA: 0x0015D56F File Offset: 0x0015B76F
			internal static object AutoGeneratedGetMemberValue_rewardGold(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._rewardGold;
			}

			// Token: 0x06004C15 RID: 19477 RVA: 0x0015D581 File Offset: 0x0015B781
			internal static object AutoGeneratedGetMemberValue_bribeGold(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._bribeGold;
			}

			// Token: 0x06004C16 RID: 19478 RVA: 0x0015D593 File Offset: 0x0015B793
			internal static object AutoGeneratedGetMemberValue_persuasionTriedOnce(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._persuasionTriedOnce;
			}

			// Token: 0x06004C17 RID: 19479 RVA: 0x0015D5A5 File Offset: 0x0015B7A5
			internal static object AutoGeneratedGetMemberValue_playerStartsQuestLog(object o)
			{
				return ((GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest)o)._playerStartsQuestLog;
			}

			// Token: 0x17000F75 RID: 3957
			// (get) Token: 0x06004C18 RID: 19480 RVA: 0x0015D5B2 File Offset: 0x0015B7B2
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=zKHkS5Gf}Gang leader needs weapons", null);
				}
			}

			// Token: 0x17000F76 RID: 3958
			// (get) Token: 0x06004C19 RID: 19481 RVA: 0x0015D5BF File Offset: 0x0015B7BF
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F77 RID: 3959
			// (get) Token: 0x06004C1A RID: 19482 RVA: 0x0015D5C4 File Offset: 0x0015B7C4
			private TextObject PlayerStartsQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=B3WyJjBx}{QUEST_GIVER.LINK}, a gang leader from {SETTLEMENT}, asked you to buy some weapons for {?QUEST_GIVER.GENDER}her{?}his{\\?} private business. {?QUEST_GIVER.GENDER}She{?}He{\\?} offered you {REWARD_GOLD}{GOLD_ICON} for their delivery. {?QUEST_GIVER.GENDER}She{?}He{\\?} asked you to buy {NEEDED_AMOUNT} {NEEDED_TYPE} and deliver them to {SETTLEMENT} where {QUEST_GIVER.LINK}'s men will be waiting for you. {?QUEST_GIVER.GENDER}She{?}He{\\?} promised to give you {REWARD_GOLD}{GOLD_ICON} for your troubles.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("SETTLEMENT", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("NEEDED_AMOUNT", this._requestedWeaponAmount);
					textObject.SetTextVariable("NEEDED_TYPE", GangLeaderNeedsWeaponsIssueQuestBehavior.GetNeededClassTextObject(this._requestedWeaponClass));
					textObject.SetTextVariable("REWARD_GOLD", this._rewardGold);
					GameTexts.SetVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
					return textObject;
				}
			}

			// Token: 0x17000F78 RID: 3960
			// (get) Token: 0x06004C1B RID: 19483 RVA: 0x0015D65C File Offset: 0x0015B85C
			private TextObject SuccessQuestLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=R6V2Jv3a}You have delivered the weapons to the {QUEST_GIVER.LINK} as promised.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F79 RID: 3961
			// (get) Token: 0x06004C1C RID: 19484 RVA: 0x0015D690 File Offset: 0x0015B890
			private TextObject FailPlayerDefeatedAgainstGuardsLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=XrxCaoT2}You have failed to deliver the weapons to the {QUEST_GIVER.LINK}.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F7A RID: 3962
			// (get) Token: 0x06004C1D RID: 19485 RVA: 0x0015D6C4 File Offset: 0x0015B8C4
			private TextObject FailQuestTimedOutLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=4n71Xoyq}You have failed to bring the weapons to the {QUEST_GIVER.LINK} in time.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F7B RID: 3963
			// (get) Token: 0x06004C1E RID: 19486 RVA: 0x0015D6F8 File Offset: 0x0015B8F8
			private TextObject OwnerOfQuestSettlementIsPlayerClanLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=Txtwv90o}Your clan has conquered the town into which you are trying to smuggle weapons. As the {?PLAYER.GENDER}lady{?}lord{\\?} of the town you cannot get involved in this kind of activity. Your agreement with the {QUEST_GIVER.LINK} has canceled.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					StringHelpers.SetCharacterProperties("PLAYER", CharacterObject.PlayerCharacter, textObject, false);
					return textObject;
				}
			}

			// Token: 0x06004C1F RID: 19487 RVA: 0x0015D73C File Offset: 0x0015B93C
			public GangLeaderNeedsWeaponsIssueQuest(string questId, Hero questGiver, CampaignTime dueTime, int rewardGold, int randomForRequiredWeaponClass, int requestedWeaponAmount, float issueDifficulty, int averagePrice) : base(questId, questGiver, dueTime, rewardGold)
			{
				this._randomForRequiredWeaponClass = randomForRequiredWeaponClass;
				this._requestedWeaponClass = GangLeaderNeedsWeaponsIssueQuestBehavior._canBeRequestedWeaponClassList[this._randomForRequiredWeaponClass];
				this._requestedWeaponAmount = requestedWeaponAmount;
				this._weaponsThatGuardTook = new Dictionary<EquipmentElement, int>();
				this._issueDifficulty = issueDifficulty;
				this._rewardGold = (float)rewardGold;
				this._bribeGold = averagePrice * requestedWeaponAmount / 4;
				this.SetDialogs();
				base.InitializeQuestOnCreation();
			}

			// Token: 0x06004C20 RID: 19488 RVA: 0x0015D7AB File Offset: 0x0015B9AB
			protected override void InitializeQuestOnGameLoad()
			{
				this.SetDialogs();
				this._requestedWeaponClass = GangLeaderNeedsWeaponsIssueQuestBehavior._canBeRequestedWeaponClassList[this._randomForRequiredWeaponClass];
			}

			// Token: 0x06004C21 RID: 19489 RVA: 0x0015D7C5 File Offset: 0x0015B9C5
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004C22 RID: 19490 RVA: 0x0015D7C8 File Offset: 0x0015B9C8
			protected override void RegisterEvents()
			{
				CampaignEvents.SettlementEntered.AddNonSerializedListener(this, new Action<MobileParty, Settlement, Hero>(this.OnSettlementEnter));
				CampaignEvents.OnSettlementLeftEvent.AddNonSerializedListener(this, new Action<MobileParty, Settlement>(this.OnSettlementLeft));
				CampaignEvents.PlayerInventoryExchangeEvent.AddNonSerializedListener(this, new Action<List<ValueTuple<ItemRosterElement, int>>, List<ValueTuple<ItemRosterElement, int>>, bool>(this.OnPlayerInventoryChanged));
				CampaignEvents.OnNewItemCraftedEvent.AddNonSerializedListener(this, new Action<ItemObject, ItemModifier, bool>(this.OnItemCrafted));
				CampaignEvents.GameMenuOpened.AddNonSerializedListener(this, new Action<MenuCallbackArgs>(this.OnGameMenuOpened));
				CampaignEvents.OnSettlementOwnerChangedEvent.AddNonSerializedListener(this, new Action<Settlement, bool, Hero, Hero, Hero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail>(this.OnSettlementOwnerChanged));
				CampaignEvents.OnEquipmentSmeltedByHeroEvent.AddNonSerializedListener(this, new Action<Hero, EquipmentElement>(this.OnEquipmentSmeltedByHero));
			}

			// Token: 0x06004C23 RID: 19491 RVA: 0x0015D876 File Offset: 0x0015BA76
			protected override void OnBeforeTimedOut(ref bool completeWithSuccess, ref bool doNotResolveTheQuest)
			{
				this.GiveBackPlayersWeaponsOnCancelOrTimeOut();
			}

			// Token: 0x06004C24 RID: 19492 RVA: 0x0015D87E File Offset: 0x0015BA7E
			public override void OnCanceled()
			{
				this.GiveBackPlayersWeaponsOnCancelOrTimeOut();
			}

			// Token: 0x06004C25 RID: 19493 RVA: 0x0015D888 File Offset: 0x0015BA88
			private void GiveBackPlayersWeaponsOnCancelOrTimeOut()
			{
				if (this._weaponsThatGuardTook.Count > 0)
				{
					foreach (KeyValuePair<EquipmentElement, int> keyValuePair in this._weaponsThatGuardTook)
					{
						PartyBase.MainParty.ItemRoster.AddToCounts(keyValuePair.Key, keyValuePair.Value);
					}
				}
			}

			// Token: 0x06004C26 RID: 19494 RVA: 0x0015D900 File Offset: 0x0015BB00
			private void OnEquipmentSmeltedByHero(Hero hero, EquipmentElement equipmentElement)
			{
				if (hero.PartyBelongedTo == MobileParty.MainParty)
				{
					ItemObject item = equipmentElement.Item;
					if (item.WeaponComponent != null && item.WeaponComponent.PrimaryWeapon.WeaponClass == this._requestedWeaponClass)
					{
						this.SetCurrentItemAmount(this._collectedItemAmount - 1);
					}
				}
			}

			// Token: 0x06004C27 RID: 19495 RVA: 0x0015D950 File Offset: 0x0015BB50
			private void OnItemCrafted(ItemObject itemObject, ItemModifier overriddenItemModifier, bool isCraftingOrderItem)
			{
				if (!isCraftingOrderItem && itemObject.WeaponComponent != null && itemObject.WeaponComponent.PrimaryWeapon.WeaponClass == this._requestedWeaponClass)
				{
					this.SetCurrentItemAmount(this._collectedItemAmount + 1);
				}
			}

			// Token: 0x06004C28 RID: 19496 RVA: 0x0015D983 File Offset: 0x0015BB83
			private void SetCurrentItemAmount(int value)
			{
				this._collectedItemAmount = value;
				JournalLog playerStartsQuestLog = this._playerStartsQuestLog;
				if (playerStartsQuestLog == null)
				{
					return;
				}
				playerStartsQuestLog.UpdateCurrentProgress(this._collectedItemAmount);
			}

			// Token: 0x06004C29 RID: 19497 RVA: 0x0015D9A2 File Offset: 0x0015BBA2
			private void OnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
			{
				if (settlement == base.QuestGiver.CurrentSettlement && newOwner == Hero.MainHero)
				{
					base.AddLog(this.OwnerOfQuestSettlementIsPlayerClanLogText, false);
					base.CompleteQuestWithCancel(null);
				}
			}

			// Token: 0x06004C2A RID: 19498 RVA: 0x0015D9D0 File Offset: 0x0015BBD0
			private void OnGameMenuOpened(MenuCallbackArgs args)
			{
				if (args.MenuContext.GameMenu.StringId == "town" && Campaign.Current.GameMenuManager.NextLocation == null && GameStateManager.Current.ActiveState is MapState)
				{
					if (this._checkForBattleResult && PlayerEncounter.Battle != null && PlayerEncounter.Battle.InvolvedParties.Any((PartyBase x) => x == this._guardsParty.Party))
					{
						bool flag = PlayerEncounter.Battle.WinningSide == PlayerEncounter.Battle.PlayerSide;
						this._checkForBattleResult = false;
						PlayerEncounter.Finish(true);
						if (flag)
						{
							this.PlayerDodgedGuards();
						}
						else
						{
							this.PlayerDefeatedAgainstGuards();
						}
					}
					if (this._startBattleMission)
					{
						this._startBattleMission = false;
						this.StartFight();
					}
					if (this._playerGoBack)
					{
						PlayerEncounter.LeaveEncounter = true;
						PlayerEncounter.Finish(true);
						this._playerGoBack = false;
					}
				}
			}

			// Token: 0x06004C2B RID: 19499 RVA: 0x0015DAB3 File Offset: 0x0015BCB3
			private void OnPlayerInventoryChanged(List<ValueTuple<ItemRosterElement, int>> purchasedItems, List<ValueTuple<ItemRosterElement, int>> soldItems, bool isTrading)
			{
				this.CalculateAndSetRequestedItemCountOnPlayer();
			}

			// Token: 0x06004C2C RID: 19500 RVA: 0x0015DABC File Offset: 0x0015BCBC
			private void OnSettlementLeft(MobileParty party, Settlement settlement)
			{
				if (settlement == base.QuestGiver.CurrentSettlement && party == MobileParty.MainParty)
				{
					if (this._weaponsThatGuardTook.Count > 0)
					{
						int num = 1500;
						bool flag = false;
						foreach (KeyValuePair<EquipmentElement, int> keyValuePair in (from x in this._weaponsThatGuardTook
						orderby x.Key.Item.Value
						select x).ToList<KeyValuePair<EquipmentElement, int>>())
						{
							int num2 = 0;
							int num3 = 0;
							while (num3 < keyValuePair.Value && num > 0)
							{
								if ((double)MBRandom.RandomFloat >= 0.6)
								{
									num2++;
									num -= keyValuePair.Key.Item.Value;
									flag = true;
								}
								num3++;
							}
							if (keyValuePair.Value > num2)
							{
								PartyBase.MainParty.ItemRoster.AddToCounts(keyValuePair.Key, keyValuePair.Value - num2);
							}
						}
						if (flag)
						{
							MBInformationManager.AddQuickInformation(new TextObject("{=Ibm1A68t}The guards gave your weapons back to you but you noticed something missing.", null), 0, null, "");
						}
						else
						{
							MBInformationManager.AddQuickInformation(new TextObject("{=isGIZ18i}The guards gave all your weapons back to you.", null), 0, null, "");
						}
						this._weaponsThatGuardTook.Clear();
						this.CalculateAndSetRequestedItemCountOnPlayer();
					}
					if (this._guardsParty != null)
					{
						EnterSettlementAction.ApplyForParty(this._guardsParty, base.QuestGiver.CurrentSettlement);
						this._guardsParty.IsVisible = false;
						this._guardsParty.IsActive = false;
					}
				}
			}

			// Token: 0x06004C2D RID: 19501 RVA: 0x0015DC60 File Offset: 0x0015BE60
			private void OnSettlementEnter(MobileParty party, Settlement settlement, Hero hero)
			{
				if (!this._playerDodgedGuards && party == MobileParty.MainParty && settlement == base.QuestGiver.CurrentSettlement && MobileParty.MainParty.Army == null && Campaign.Current.GameMenuManager.NextLocation == null && GameStateManager.Current.ActiveState is MapState && PlayerEncounter.EncounterSettlement != null)
				{
					this.CalculateAndSetRequestedItemCountOnPlayer();
					if (this._collectedItemAmount >= this._requestedWeaponAmount / 3 && !this._playerGoBack)
					{
						if (this._guardsParty == null)
						{
							this.CreateGuardsParty();
						}
						ConversationCharacterData conversationPartnerData = new ConversationCharacterData(ConversationHelper.GetConversationCharacterPartyLeader(this._guardsParty.Party), null, false, false, false, true, false, false);
						CampaignMapConversation.OpenConversation(new ConversationCharacterData(CharacterObject.PlayerCharacter, PartyBase.MainParty, false, false, false, false, false, false), conversationPartnerData);
					}
				}
			}

			// Token: 0x06004C2E RID: 19502 RVA: 0x0015DD34 File Offset: 0x0015BF34
			private void CreateGuardsParty()
			{
				this._guardsParty = MobileParty.CreateParty("weapon_smuggling_quest_guards_party_" + GangLeaderNeedsWeaponsIssueQuestBehavior.CreatedPartyCount, null, null);
				TextObject customName = new TextObject("{=7aaAWc01}Guard's Party", null);
				this._guardsParty.InitializeMobilePartyAtPosition(new TroopRoster(this._guardsParty.Party), new TroopRoster(this._guardsParty.Party), base.QuestGiver.CurrentSettlement.GatePosition);
				this._guardsParty.SetCustomName(customName);
				this._guardsParty.SetCustomHomeSettlement(base.QuestGiver.CurrentSettlement);
				this._guardsParty.Party.SetCustomOwner(base.QuestGiver.CurrentSettlement.OwnerClan.Leader);
				CharacterObject character = CharacterObject.All.First((CharacterObject x) => x.StringId == "guard_" + this._guardsParty.HomeSettlement.Culture.StringId);
				this._guardsParty.MemberRoster.AddToCounts(character, 1, true, 0, 0, true, -1);
				this._guardsParty.SetPartyUsedByQuest(true);
				this._guardsParty.Ai.DisableAi();
				float num = 5f + 15f * this._issueDifficulty;
				this._guardsParty.MemberRoster.AddToCounts(this._guardsParty.HomeSettlement.Culture.MeleeMilitiaTroop, (int)num, false, 0, 0, true, -1);
				EnterSettlementAction.ApplyForParty(this._guardsParty, base.QuestGiver.CurrentSettlement);
				this._guardsParty.IsVisible = false;
				this._guardsParty.ActualClan = base.QuestGiver.CurrentSettlement.OwnerClan;
			}

			// Token: 0x06004C2F RID: 19503 RVA: 0x0015DEB8 File Offset: 0x0015C0B8
			protected override void SetDialogs()
			{
				Campaign.Current.ConversationManager.AddDialogFlow(this.GetGuardDialogFlow(), this);
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=nQoAsBZY}When you enter the town my men will take the weapons from you. Good luck.", null), null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(new TextObject("{=CQH7E6Gr}What about my weapons?[if:convo_confused_normal][ib:hip]", null), null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).BeginPlayerOptions().PlayerOption(new TextObject("{=RbToDs0n}Here is your cargo. Now it's time for payment.", null), null).Condition(new ConversationSentence.OnConditionDelegate(this.CheckIfPlayerHasEnoughRequestedWeapons)).NpcLine(new TextObject("{=nixINYwE}Yes of course. It was a pleasure doing business with you.[if:convo_mocking_aristocratic]", null), null, null).Consequence(delegate
				{
					Campaign.Current.ConversationManager.ConversationEndOneShot += this.PlayerSuccessfullyDeliveredWeapons;
				}).CloseDialog().PlayerOption(new TextObject("{=bj49Bq15}It's not that easy to find what you wanted. Be patient, please.", null), null).NpcLine(new TextObject("{=avFXbBLV}I know how it is. Just bring me the weapons.[if:convo_bored2]", null), null, null).EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06004C30 RID: 19504 RVA: 0x0015DFD7 File Offset: 0x0015C1D7
			private bool CheckIfPlayerHasEnoughRequestedWeapons()
			{
				this.CalculateAndSetRequestedItemCountOnPlayer();
				return this._collectedItemAmount >= this._requestedWeaponAmount;
			}

			// Token: 0x06004C31 RID: 19505 RVA: 0x0015DFF0 File Offset: 0x0015C1F0
			private void CalculateAndSetRequestedItemCountOnPlayer()
			{
				int num = 0;
				foreach (ItemRosterElement itemRosterElement in PartyBase.MainParty.ItemRoster)
				{
					if (itemRosterElement.EquipmentElement.Item != null && itemRosterElement.EquipmentElement.Item.WeaponComponent != null && itemRosterElement.EquipmentElement.Item.WeaponComponent.PrimaryWeapon.WeaponClass == this._requestedWeaponClass)
					{
						num += itemRosterElement.Amount;
					}
				}
				this.SetCurrentItemAmount(num);
			}

			// Token: 0x06004C32 RID: 19506 RVA: 0x0015E09C File Offset: 0x0015C29C
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				this._playerStartsQuestLog = base.AddDiscreteLog(this.PlayerStartsQuestLogText, new TextObject("{=9j7LJk60}Collected Items", null), this._collectedItemAmount, this._requestedWeaponAmount, null, false);
				this.CalculateAndSetRequestedItemCountOnPlayer();
			}

			// Token: 0x06004C33 RID: 19507 RVA: 0x0015E0D8 File Offset: 0x0015C2D8
			private DialogFlow GetGuardDialogFlow()
			{
				TextObject npcText = new TextObject("{=wBBidWVw}What have we here? You can't enter the town with so many weapons. Hand them over! You can retrieve them when you leave.[if:convo_thinking][closed2]", null);
				TextObject text = new TextObject("{=oVAtPtsu}Clear the way! We don't want to use force!", null);
				TextObject text2 = new TextObject("{=JL204Kc0}Sure... sure. We'll hand them over..", null);
				TextObject text3 = new TextObject("{=nlCa3tW8}You seem like a reasonable man. What is your price?", null);
				TextObject text4 = new TextObject("{=VUjaLmIH}Relax. We have permission. Let us pass. ", null);
				TextObject text5 = new TextObject("{=tGFgar0U}Fine. We won't enter at all, then. Good bye.", null);
				TextObject textObject = new TextObject("{=Qb7N6txQ}Mmm. For {BRIBE_COST}{GOLD_ICON} denars, I could be persuaded that this is just harmless scrap metal...[if:convo_mocking_aristocratic][ib:confident]", null);
				textObject.SetTextVariable("BRIBE_COST", this._bribeGold);
				textObject.SetTextVariable("GOLD_ICON", "{=!}<img src=\"General\\Icons\\Coin@2x\" extend=\"8\">");
				DialogFlow dialogFlow = DialogFlow.CreateDialogFlow("start", 125).NpcLine(npcText, null, null).Condition(new ConversationSentence.OnConditionDelegate(this.DialogStartCondition)).Consequence(delegate
				{
					this._task = this.GetPersuasionTask();
				}).BeginPlayerOptions().PlayerOption(text, null).ClickableCondition(new ConversationSentence.OnClickableConditionDelegate(this.CheckPlayerHealth)).BeginNpcOptions().NpcOption(new TextObject("{=NcQZz4N2}This is my last warning! It would be better for both sides if you don't resist.[if:convo_grave][ib:closed]", null), new ConversationSentence.OnConditionDelegate(this.CheckPlayersPartySize), null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=NTlbbrwB}If there will be a fight, then we will fight", null), null).NpcLine(new TextObject("{=h5np5kcC}All right, all right... We don't want any trouble here, okay? Go on.[if:convo_contemptuous]", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.PlayerDodgeGuardsLowCrimeRating)).CloseDialog().PlayerOption(new TextObject("{=pfxG5Ubu}Fine, fine. Take our weapons.", null), null).NpcLine(new TextObject("{=A8lvIDVw}Wise decision! Now move along![if:convo_angry] ", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.DeleteAllWeaponsFromPlayer)).CloseDialog().EndPlayerOptions().NpcOption(new TextObject("{=G632MneX}This is my last warning! Hand over your weapons![if:convo_thinking][ib:closed]", null), null, null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=NTlbbrwB}If there will be a fight, then we will fight", null), null).NpcLine(new TextObject("{=8WaoQpYn}Oh there will be one, all right.[if:convo_predatory][ib:warrior]", null), null, null).Consequence(delegate
				{
					this._startBattleMission = true;
				}).CloseDialog().PlayerOption(new TextObject("{=pfxG5Ubu}Fine, fine. Take our weapons.", null), null).NpcLine(new TextObject("{=3xyd2Dxu}Good. That saves us all trouble.[if:convo_grave][ib:warrior2]", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.DeleteAllWeaponsFromPlayer)).CloseDialog().EndPlayerOptions().EndNpcOptions().PlayerOption(text2, null).NpcLine(new TextObject("{=GyI86plp}Don't worry. I guarantee your property will be returned, if everything's in order like you say...[if:convo_calm_friendly][ib:closed]", null), null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.DeleteAllWeaponsFromPlayer)).CloseDialog().PlayerOption(text3, null).NpcLine(textObject, null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=Obk7j3ai}Here it is. Now let us pass", null), null).ClickableCondition(new ConversationSentence.OnClickableConditionDelegate(this.HasPlayerEnoughMoneyToBribe)).Consequence(new ConversationSentence.OnConsequenceDelegate(this.PlayerBribeGuard)).NpcLine(new TextObject("{=musbt5Hm}Sorry for the interruption. Go on please...[if:convo_bored2]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=d5ztuP3P}That's too much.", null), null).NpcLine(new TextObject("{=49IwOe5E}As you wish...[if:convo_normal]", null), null, null).GotoDialogState("start").EndPlayerOptions().PlayerOption(text4, null).Condition(() => !this._persuasionTriedOnce).Consequence(delegate
				{
					this._persuasionTriedOnce = true;
				}).GotoDialogState("start_guard_persuasion").PlayerOption(text5, null).NpcLine(new TextObject("{=xvYDbEUa}All right. Go on.[if:convo_bored]", null), null, null).Consequence(delegate
				{
					this._playerGoBack = true;
				}).CloseDialog().EndPlayerOptions();
				this.AddPersuasionDialogs(dialogFlow);
				return dialogFlow;
			}

			// Token: 0x06004C34 RID: 19508 RVA: 0x0015E41C File Offset: 0x0015C61C
			private bool CheckPlayerHealth(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				if (Hero.MainHero.IsWounded)
				{
					explanation = new TextObject("{=yNMrF2QF}You are wounded", null);
					return false;
				}
				return true;
			}

			// Token: 0x06004C35 RID: 19509 RVA: 0x0015E444 File Offset: 0x0015C644
			private void AddPersuasionDialogs(DialogFlow dialog)
			{
				dialog.AddDialogLine("guard_persuation_weapon_smuggling_check_accepted", "start_guard_persuasion", "guard_persuation_weapon_smuggling_start_reservation", "{=v5tPWFFu}Then, what is the purpose of this?", new ConversationSentence.OnConditionDelegate(this.persuasion_start_with_guards_on_condition), new ConversationSentence.OnConsequenceDelegate(this.persuasion_start_with_guards_on_consequence), this, 100, null, null, null);
				dialog.AddDialogLine("guard_persuation_weapon_smuggling_rejected", "guard_persuation_weapon_smuggling_start_reservation", "start", "{=!}{FAILED_PERSUASION_LINE}", new ConversationSentence.OnConditionDelegate(this.persuasion_failed_with_guards_on_condition), new ConversationSentence.OnConsequenceDelegate(this.persuasion_rejected_with_guards_on_consequence), this, 100, null, null, null);
				dialog.AddDialogLine("guard_persuation_weapon_smuggling_attempt", "guard_persuation_weapon_smuggling_start_reservation", "guard_persuation_weapon_smuggling_select_option", "{=D9SS2Oh0}I'm going to need you to tell me a little more.", () => !this.persuasion_failed_with_guards_on_condition(), null, this, 100, null, null, null);
				dialog.AddDialogLine("guard_persuation_weapon_smuggling_success", "guard_persuation_weapon_smuggling_start_reservation", "close_window", "{=kD8yLgRv}Go on. But I have my eye on you.", new ConversationSentence.OnConditionDelegate(ConversationManager.GetPersuasionProgressSatisfied), new ConversationSentence.OnConsequenceDelegate(this.persuasion_complete_with_guards_on_consequence), this, 200, null, null, null);
				string id = "guard_persuation_weapon_smuggling_select_option_1";
				string inputToken = "guard_persuation_weapon_smuggling_select_option";
				string outputToken = "guard_persuation_weapon_smuggling_selected_option_response";
				string text = "{=!}{GUARDS_PERSUADE_ATTEMPT_1}";
				ConversationSentence.OnConditionDelegate conditionDelegate = new ConversationSentence.OnConditionDelegate(this.guard_persuation_weapon_smuggling_select_option_1_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate = new ConversationSentence.OnConsequenceDelegate(this.guard_persuation_weapon_smuggling_select_option_1_on_consequence);
				ConversationSentence.OnPersuasionOptionDelegate persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.guard_persuation_weapon_smuggling_setup_option_1);
				ConversationSentence.OnClickableConditionDelegate clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.guard_persuation_weapon_smuggling_clickable_option_1_on_condition);
				dialog.AddPlayerLine(id, inputToken, outputToken, text, conditionDelegate, consequenceDelegate, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				string id2 = "guard_persuation_weapon_smuggling_select_option_2";
				string inputToken2 = "guard_persuation_weapon_smuggling_select_option";
				string outputToken2 = "guard_persuation_weapon_smuggling_selected_option_response";
				string text2 = "{=!}{GUARDS_PERSUADE_ATTEMPT_2}";
				ConversationSentence.OnConditionDelegate conditionDelegate2 = new ConversationSentence.OnConditionDelegate(this.guard_persuation_weapon_smuggling_select_option_2_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate2 = new ConversationSentence.OnConsequenceDelegate(this.guard_persuation_weapon_smuggling_select_option_2_on_consequence);
				persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.guard_persuation_weapon_smuggling_setup_option_2);
				clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.guard_persuation_weapon_smuggling_clickable_option_2_on_condition);
				dialog.AddPlayerLine(id2, inputToken2, outputToken2, text2, conditionDelegate2, consequenceDelegate2, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				string id3 = "guard_persuation_weapon_smuggling_select_option_3";
				string inputToken3 = "guard_persuation_weapon_smuggling_select_option";
				string outputToken3 = "guard_persuation_weapon_smuggling_selected_option_response";
				string text3 = "{=!}{GUARDS_PERSUADE_ATTEMPT_3}";
				ConversationSentence.OnConditionDelegate conditionDelegate3 = new ConversationSentence.OnConditionDelegate(this.guard_persuation_weapon_smuggling_select_option_3_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate3 = new ConversationSentence.OnConsequenceDelegate(this.guard_persuation_weapon_smuggling_select_option_3_on_consequence);
				persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.guard_persuation_weapon_smuggling_setup_option_3);
				clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.guard_persuation_weapon_smuggling_clickable_option_3_on_condition);
				dialog.AddPlayerLine(id3, inputToken3, outputToken3, text3, conditionDelegate3, consequenceDelegate3, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				dialog.AddDialogLine("guard_persuation_weapon_smuggling_select_option_reaction", "guard_persuation_weapon_smuggling_selected_option_response", "guard_persuation_weapon_smuggling_start_reservation", "{=!}{PERSUASION_REACTION}", new ConversationSentence.OnConditionDelegate(this.guard_persuation_weapon_smuggling_selected_option_response_on_condition), new ConversationSentence.OnConsequenceDelegate(this.guard_persuation_weapon_smuggling_selected_option_response_on_consequence), this, 100, null, null, null);
			}

			// Token: 0x06004C36 RID: 19510 RVA: 0x0015E662 File Offset: 0x0015C862
			private void persuasion_start_with_guards_on_consequence()
			{
				ConversationManager.StartPersuasion(2f, 1f, 0f, 2f, 2f, 0f, PersuasionDifficulty.VeryHard);
			}

			// Token: 0x06004C37 RID: 19511 RVA: 0x0015E688 File Offset: 0x0015C888
			private bool persuasion_start_with_guards_on_condition()
			{
				return this._guardsParty != null && CharacterObject.OneToOneConversationCharacter == ConversationHelper.GetConversationCharacterPartyLeader(this._guardsParty.Party);
			}

			// Token: 0x06004C38 RID: 19512 RVA: 0x0015E6AC File Offset: 0x0015C8AC
			private bool persuasion_failed_with_guards_on_condition()
			{
				if (this._task.Options.All((PersuasionOptionArgs x) => x.IsBlocked) && !ConversationManager.GetPersuasionProgressSatisfied())
				{
					MBTextManager.SetTextVariable("FAILED_PERSUASION_LINE", this._task.FinalFailLine, false);
					return true;
				}
				return false;
			}

			// Token: 0x06004C39 RID: 19513 RVA: 0x0015E70A File Offset: 0x0015C90A
			private void persuasion_rejected_with_guards_on_consequence()
			{
				PlayerEncounter.LeaveEncounter = false;
				ConversationManager.EndPersuasion();
			}

			// Token: 0x06004C3A RID: 19514 RVA: 0x0015E717 File Offset: 0x0015C917
			private void persuasion_complete_with_guards_on_consequence()
			{
				this.PlayerDodgedGuards();
				PlayerEncounter.LeaveEncounter = true;
				ConversationManager.EndPersuasion();
			}

			// Token: 0x06004C3B RID: 19515 RVA: 0x0015E72C File Offset: 0x0015C92C
			private PersuasionTask GetPersuasionTask()
			{
				PersuasionTask persuasionTask = new PersuasionTask(0);
				persuasionTask.FinalFailLine = new TextObject("{=XCJGl82o}Do you think you can pull one over on me? Now hand over the weapons![if:convo_furious][ib:aggressive]", null);
				persuasionTask.TryLaterLine = new TextObject("{=!}TODO", null);
				persuasionTask.SpokenLine = new TextObject("{=6P1ruzsC}Maybe...", null);
				PersuasionOptionArgs option = new PersuasionOptionArgs(DefaultSkills.Roguery, DefaultTraits.RogueSkills, TraitEffect.Positive, PersuasionArgumentStrength.Hard, false, new TextObject("{=1hbos200}Here are some documents from the chancellery.", null), null, false, false, false);
				persuasionTask.AddOptionToTask(option);
				PersuasionOptionArgs option2 = new PersuasionOptionArgs(DefaultSkills.Roguery, DefaultTraits.Calculating, TraitEffect.Positive, PersuasionArgumentStrength.Normal, false, new TextObject("{=UHCKXapl}The metalworkers' guild asked for them. Don't worry, they'll be melted into scrap.", null), null, false, false, false);
				persuasionTask.AddOptionToTask(option2);
				PersuasionOptionArgs option3 = new PersuasionOptionArgs(DefaultSkills.Charm, DefaultTraits.RogueSkills, TraitEffect.Positive, PersuasionArgumentStrength.VeryHard, false, new TextObject("{=8Wa6OxG8}It's secret. You must be new in your post if you don't know who I am and what I do.", null), null, false, false, false);
				persuasionTask.AddOptionToTask(option3);
				return persuasionTask;
			}

			// Token: 0x06004C3C RID: 19516 RVA: 0x0015E7F0 File Offset: 0x0015C9F0
			private bool guard_persuation_weapon_smuggling_selected_option_response_on_condition()
			{
				PersuasionOptionResult item = ConversationManager.GetPersuasionChosenOptions().Last<Tuple<PersuasionOptionArgs, PersuasionOptionResult>>().Item2;
				MBTextManager.SetTextVariable("PERSUASION_REACTION", PersuasionHelper.GetDefaultPersuasionOptionReaction(item), false);
				if (item == PersuasionOptionResult.CriticalFailure)
				{
					this._task.BlockAllOptions();
				}
				return true;
			}

			// Token: 0x06004C3D RID: 19517 RVA: 0x0015E830 File Offset: 0x0015CA30
			private void guard_persuation_weapon_smuggling_selected_option_response_on_consequence()
			{
				Tuple<PersuasionOptionArgs, PersuasionOptionResult> tuple = ConversationManager.GetPersuasionChosenOptions().Last<Tuple<PersuasionOptionArgs, PersuasionOptionResult>>();
				float difficulty = Campaign.Current.Models.PersuasionModel.GetDifficulty(PersuasionDifficulty.VeryHard);
				float moveToNextStageChance;
				float blockRandomOptionChance;
				Campaign.Current.Models.PersuasionModel.GetEffectChances(tuple.Item1, out moveToNextStageChance, out blockRandomOptionChance, difficulty);
				this._task.ApplyEffects(moveToNextStageChance, blockRandomOptionChance);
			}

			// Token: 0x06004C3E RID: 19518 RVA: 0x0015E88C File Offset: 0x0015CA8C
			private bool guard_persuation_weapon_smuggling_select_option_1_on_condition()
			{
				if (this._task.Options.Count > 0)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(0), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(0).Line);
					MBTextManager.SetTextVariable("GUARDS_PERSUADE_ATTEMPT_1", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x06004C3F RID: 19519 RVA: 0x0015E90C File Offset: 0x0015CB0C
			private bool guard_persuation_weapon_smuggling_select_option_2_on_condition()
			{
				if (this._task.Options.Count > 1)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(1), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(1).Line);
					MBTextManager.SetTextVariable("GUARDS_PERSUADE_ATTEMPT_2", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x06004C40 RID: 19520 RVA: 0x0015E98C File Offset: 0x0015CB8C
			private bool guard_persuation_weapon_smuggling_select_option_3_on_condition()
			{
				if (this._task.Options.Count > 2)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(2), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(2).Line);
					MBTextManager.SetTextVariable("GUARDS_PERSUADE_ATTEMPT_3", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x06004C41 RID: 19521 RVA: 0x0015EA0C File Offset: 0x0015CC0C
			private void guard_persuation_weapon_smuggling_select_option_1_on_consequence()
			{
				if (this._task.Options.Count > 0)
				{
					this._task.Options[0].BlockTheOption(true);
				}
			}

			// Token: 0x06004C42 RID: 19522 RVA: 0x0015EA38 File Offset: 0x0015CC38
			private void guard_persuation_weapon_smuggling_select_option_2_on_consequence()
			{
				if (this._task.Options.Count > 1)
				{
					this._task.Options[1].BlockTheOption(true);
				}
			}

			// Token: 0x06004C43 RID: 19523 RVA: 0x0015EA64 File Offset: 0x0015CC64
			private void guard_persuation_weapon_smuggling_select_option_3_on_consequence()
			{
				if (this._task.Options.Count > 2)
				{
					this._task.Options[2].BlockTheOption(true);
				}
			}

			// Token: 0x06004C44 RID: 19524 RVA: 0x0015EA90 File Offset: 0x0015CC90
			private PersuasionOptionArgs guard_persuation_weapon_smuggling_setup_option_1()
			{
				return this._task.Options.ElementAt(0);
			}

			// Token: 0x06004C45 RID: 19525 RVA: 0x0015EAA3 File Offset: 0x0015CCA3
			private PersuasionOptionArgs guard_persuation_weapon_smuggling_setup_option_2()
			{
				return this._task.Options.ElementAt(1);
			}

			// Token: 0x06004C46 RID: 19526 RVA: 0x0015EAB6 File Offset: 0x0015CCB6
			private PersuasionOptionArgs guard_persuation_weapon_smuggling_setup_option_3()
			{
				return this._task.Options.ElementAt(2);
			}

			// Token: 0x06004C47 RID: 19527 RVA: 0x0015EACC File Offset: 0x0015CCCC
			private bool guard_persuation_weapon_smuggling_clickable_option_1_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 0)
				{
					hintText = (this._task.Options.ElementAt(0).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(0).IsBlocked;
				}
				return false;
			}

			// Token: 0x06004C48 RID: 19528 RVA: 0x0015EB38 File Offset: 0x0015CD38
			private bool guard_persuation_weapon_smuggling_clickable_option_2_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 1)
				{
					hintText = (this._task.Options.ElementAt(1).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(1).IsBlocked;
				}
				return false;
			}

			// Token: 0x06004C49 RID: 19529 RVA: 0x0015EBA4 File Offset: 0x0015CDA4
			private bool guard_persuation_weapon_smuggling_clickable_option_3_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 2)
				{
					hintText = (this._task.Options.ElementAt(2).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(2).IsBlocked;
				}
				return false;
			}

			// Token: 0x06004C4A RID: 19530 RVA: 0x0015EC0F File Offset: 0x0015CE0F
			private bool DialogStartCondition()
			{
				return !this._playerDodgedGuards && this._guardsParty != null && CharacterObject.OneToOneConversationCharacter == ConversationHelper.GetConversationCharacterPartyLeader(this._guardsParty.Party);
			}

			// Token: 0x06004C4B RID: 19531 RVA: 0x0015EC3C File Offset: 0x0015CE3C
			private void StartFight()
			{
				int upgradeLevel = base.QuestGiver.CurrentSettlement.IsTown ? base.QuestGiver.CurrentSettlement.Town.GetWallLevel() : 1;
				this._highCrimeRatingWillBeApplied = true;
				if (this._guardsParty.CurrentSettlement == null)
				{
					this._guardsParty.CurrentSettlement = base.QuestGiver.CurrentSettlement;
				}
				PlayerEncounter.RestartPlayerEncounter(this._guardsParty.Party, PartyBase.MainParty, false);
				PlayerEncounter.StartBattle();
				GameMenu.ActivateGameMenu("town");
				int num = (int)(5f + 15f * this._issueDifficulty);
				CampaignMission.OpenBattleMissionWhileEnteringSettlement(base.QuestGiver.CurrentSettlement.LocationComplex.GetLocationWithId("center").GetSceneName(upgradeLevel), upgradeLevel, num, num);
				this._checkForBattleResult = true;
			}

			// Token: 0x06004C4C RID: 19532 RVA: 0x0015ED08 File Offset: 0x0015CF08
			private void PlayerDodgeGuardsLowCrimeRating()
			{
				this.PlayerDodgedGuards();
				this._lowCrimeRatingWillBeApplied = true;
			}

			// Token: 0x06004C4D RID: 19533 RVA: 0x0015ED17 File Offset: 0x0015CF17
			private bool CheckPlayersPartySize()
			{
				return MobileParty.MainParty.MemberRoster.TotalRegulars - MobileParty.MainParty.MemberRoster.TotalWoundedRegulars > 30;
			}

			// Token: 0x06004C4E RID: 19534 RVA: 0x0015ED3C File Offset: 0x0015CF3C
			private void PlayerDodgedGuards()
			{
				MBInformationManager.AddQuickInformation(new TextObject("{=vYRbyXkz}The guards won't come after you anymore.", null), 0, null, "");
				if (this._guardsParty.IsActive && this._guardsParty.IsVisible)
				{
					DestroyPartyAction.Apply(PartyBase.MainParty, this._guardsParty);
				}
				this._playerDodgedGuards = true;
			}

			// Token: 0x06004C4F RID: 19535 RVA: 0x0015ED91 File Offset: 0x0015CF91
			private void PlayerBribeGuard()
			{
				GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, this._bribeGold, false);
				this.PlayerDodgedGuards();
			}

			// Token: 0x06004C50 RID: 19536 RVA: 0x0015EDAC File Offset: 0x0015CFAC
			private void DeleteAllWeaponsFromPlayer()
			{
				Dictionary<EquipmentElement, int> dictionary = new Dictionary<EquipmentElement, int>();
				foreach (ItemRosterElement itemRosterElement in PartyBase.MainParty.ItemRoster)
				{
					if (itemRosterElement.EquipmentElement.Item != null && !itemRosterElement.EquipmentElement.IsQuestItem && itemRosterElement.EquipmentElement.Item.WeaponComponent != null && itemRosterElement.Amount > 0 && !dictionary.ContainsKey(itemRosterElement.EquipmentElement))
					{
						dictionary.Add(itemRosterElement.EquipmentElement, itemRosterElement.Amount);
						PartyBase.MainParty.ItemRoster.AddToCounts(itemRosterElement.EquipmentElement, -itemRosterElement.Amount);
					}
				}
				this._weaponsThatGuardTook = dictionary;
				this.CalculateAndSetRequestedItemCountOnPlayer();
			}

			// Token: 0x06004C51 RID: 19537 RVA: 0x0015EE94 File Offset: 0x0015D094
			private void QuestSuccessDeleteWeaponsFromPlayer()
			{
				int num = this._requestedWeaponAmount;
				for (int i = PartyBase.MainParty.ItemRoster.Count - 1; i >= 0; i--)
				{
					ItemRosterElement itemRosterElement = PartyBase.MainParty.ItemRoster[i];
					if (itemRosterElement.EquipmentElement.Item != null && itemRosterElement.EquipmentElement.Item.WeaponComponent != null && itemRosterElement.EquipmentElement.Item.WeaponComponent.PrimaryWeapon.WeaponClass == this._requestedWeaponClass && itemRosterElement.Amount > 0)
					{
						if (num < itemRosterElement.Amount)
						{
							PartyBase.MainParty.ItemRoster.AddToCounts(itemRosterElement.EquipmentElement, -num);
							return;
						}
						PartyBase.MainParty.ItemRoster.AddToCounts(itemRosterElement.EquipmentElement, -itemRosterElement.Amount);
						num -= itemRosterElement.Amount;
					}
					if (num == 0)
					{
						break;
					}
				}
			}

			// Token: 0x06004C52 RID: 19538 RVA: 0x0015EF87 File Offset: 0x0015D187
			private bool HasPlayerEnoughMoneyToBribe(out TextObject hintText)
			{
				hintText = TextObject.Empty;
				if (Hero.MainHero.Gold < this._bribeGold)
				{
					hintText = new TextObject("{=1V6DRayw}You don't have {BRIBE_COST} denars.", null);
					hintText.SetTextVariable("BRIBE_COST", this._bribeGold);
					return false;
				}
				return true;
			}

			// Token: 0x06004C53 RID: 19539 RVA: 0x0015EFC5 File Offset: 0x0015D1C5
			private void PlayerDefeatedAgainstGuards()
			{
				base.AddLog(this.FailPlayerDefeatedAgainstGuardsLogText, false);
				base.QuestGiver.AddPower(-10f);
				this.RelationshipChangeWithQuestGiver = -5;
				base.CompleteQuestWithFail(null);
			}

			// Token: 0x06004C54 RID: 19540 RVA: 0x0015EFF4 File Offset: 0x0015D1F4
			private void PlayerSuccessfullyDeliveredWeapons()
			{
				base.AddLog(this.SuccessQuestLogText, false);
				GainRenownAction.Apply(Hero.MainHero, 2f, false);
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, (int)this._rewardGold, false);
				base.QuestGiver.AddPower(10f);
				this.RelationshipChangeWithQuestGiver = 5;
				this.QuestSuccessDeleteWeaponsFromPlayer();
				this._weaponsThatGuardTook.Clear();
				base.QuestGiver.CurrentSettlement.Town.Security -= 30f;
				if (this._lowCrimeRatingWillBeApplied)
				{
					ChangeCrimeRatingAction.Apply(base.QuestGiver.CurrentSettlement.MapFaction, 30f, true);
				}
				if (this._highCrimeRatingWillBeApplied)
				{
					ChangeCrimeRatingAction.Apply(base.QuestGiver.CurrentSettlement.MapFaction, 60f, true);
				}
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x06004C55 RID: 19541 RVA: 0x0015F0C8 File Offset: 0x0015D2C8
			public override void OnFailed()
			{
				if (this._lowCrimeRatingWillBeApplied)
				{
					ChangeCrimeRatingAction.Apply(base.QuestGiver.CurrentSettlement.MapFaction, 30f, true);
				}
				if (this._highCrimeRatingWillBeApplied)
				{
					ChangeCrimeRatingAction.Apply(base.QuestGiver.CurrentSettlement.MapFaction, 60f, true);
				}
			}

			// Token: 0x06004C56 RID: 19542 RVA: 0x0015F11B File Offset: 0x0015D31B
			protected override void OnFinalize()
			{
				if (this._guardsParty != null && this._guardsParty.IsActive)
				{
					DestroyPartyAction.Apply(PartyBase.MainParty, this._guardsParty);
				}
			}

			// Token: 0x06004C57 RID: 19543 RVA: 0x0015F142 File Offset: 0x0015D342
			protected override void OnTimedOut()
			{
				base.AddLog(this.FailQuestTimedOutLogText, false);
				base.QuestGiver.AddPower(-10f);
				this.RelationshipChangeWithQuestGiver = -5;
			}

			// Token: 0x040019AB RID: 6571
			private const int LowCrimeRatingValue = 30;

			// Token: 0x040019AC RID: 6572
			private const int HighCrimeRatingValue = 60;

			// Token: 0x040019AD RID: 6573
			private WeaponClass _requestedWeaponClass;

			// Token: 0x040019AE RID: 6574
			[SaveableField(10)]
			private int _randomForRequiredWeaponClass;

			// Token: 0x040019AF RID: 6575
			[SaveableField(20)]
			private int _requestedWeaponAmount;

			// Token: 0x040019B0 RID: 6576
			[SaveableField(30)]
			private bool _playerDodgedGuards;

			// Token: 0x040019B1 RID: 6577
			[SaveableField(40)]
			private int _collectedItemAmount;

			// Token: 0x040019B2 RID: 6578
			[SaveableField(50)]
			private bool _lowCrimeRatingWillBeApplied;

			// Token: 0x040019B3 RID: 6579
			[SaveableField(60)]
			private bool _highCrimeRatingWillBeApplied;

			// Token: 0x040019B4 RID: 6580
			[SaveableField(71)]
			private Dictionary<EquipmentElement, int> _weaponsThatGuardTook;

			// Token: 0x040019B5 RID: 6581
			[SaveableField(80)]
			private float _issueDifficulty;

			// Token: 0x040019B6 RID: 6582
			[SaveableField(90)]
			private float _rewardGold;

			// Token: 0x040019B7 RID: 6583
			[SaveableField(100)]
			private int _bribeGold;

			// Token: 0x040019B8 RID: 6584
			[SaveableField(101)]
			private bool _persuasionTriedOnce;

			// Token: 0x040019B9 RID: 6585
			private bool _checkForBattleResult;

			// Token: 0x040019BA RID: 6586
			private MobileParty _guardsParty;

			// Token: 0x040019BB RID: 6587
			private bool _startBattleMission;

			// Token: 0x040019BC RID: 6588
			private bool _playerGoBack;

			// Token: 0x040019BD RID: 6589
			private PersuasionTask _task;

			// Token: 0x040019BE RID: 6590
			private const PersuasionDifficulty Difficulty = PersuasionDifficulty.VeryHard;

			// Token: 0x040019BF RID: 6591
			[SaveableField(110)]
			private JournalLog _playerStartsQuestLog;
		}

		// Token: 0x02000629 RID: 1577
		public class GangLeaderNeedsWeaponsIssueTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x06004C63 RID: 19555 RVA: 0x0015F220 File Offset: 0x0015D420
			public GangLeaderNeedsWeaponsIssueTypeDefiner() : base(3940000)
			{
			}

			// Token: 0x06004C64 RID: 19556 RVA: 0x0015F22D File Offset: 0x0015D42D
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssue), 1, null);
				base.AddClassDefinition(typeof(GangLeaderNeedsWeaponsIssueQuestBehavior.GangLeaderNeedsWeaponsIssueQuest), 2, null);
			}
		}
	}
}
